<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">
<script type="text/javascript" src="js/ueditor1_4_3_3-utf8-jsp/utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" src="js/ueditor1_4_3_3-utf8-jsp/utf8-jsp/ueditor.all.js"></script>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.min.css" />
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js" ></script>
<title>Insert title here</title>	
<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			.box{
				width:500px;
				height:30px;
			}
			.header li {
				list-style: none;
				float: left;
				width: 80px;
				text-align: center;
				line-height: 30px;
				cursor: pointer;
			}
			.box2{
				background-color:black;
				width:100%;
			}
			.box2 ul{
				padding: 0;
			}
			.box2 ul li {
				list-style: none;
				float: left;
			}
			.box2 table{
				border-spacing: 20px;
			}
			.box2-td{
				text-align: right;
			}
			#text{
				width: 320px;
			}
</style>
<script type="text/javascript">
	$(function(){
		$(".header>li").click(function(){
			var _index=$(this).index();
			$(".header>li").eq(_index).css("border-top","2px blue solid").siblings().css("border-top","2px #ffffff solid");
			$(".box2>ul>li").eq(_index).show().siblings().hide();
		});
		$("#xdaTanFileImg").change(function(e){
			var file=$(this)[0].files[0];
    		console.log(file);

			var formObj = new FormData();
			formObj.set('image', file);
			$.ajax({
				url : 'img?action=add',
				data : formObj,
				type : 'POST',
				dataType : 'json',
				processData : false,
				contentType : false,
				success : function(e) {
				/* console.log(res.id);
				console.log(res.folder); */
					var img = $("<div style='float:left;'><img src='uploads\\"+ e.p_newname+ " ' onclick='delimg(this)' style='cursor:pointer ;width:100px'><input type='hidden' name='p_newname' value='"+e.p_newname+"'><input type='hidden' name='p_oldname' value='"+e.p_oldname+"'><input type='hidden' name='p_width' value='"+e.p_width+"'><input type='hidden' name='p_height' value='"+e.p_height+"'><input type='hidden' name='p_size' value='"+e.p_size+"'><a href='javascript:;' id='close'><i class='fa fa-close'></i></a></div>");
					$("#yulan").append(img);
					img.children("#close").click(function(){
		                $(this).parent().remove();
		            });
				},
				error:function(e){
					msgbox('提示','操作失败!','',null,0,'error');
				}
			});
		});
		$(".closeimg").click(function(){
			var pcode=$(this).attr("id");
			var img = $("<input type='hidden' name='delete_code' value='"+pcode+"'>");
			$("#yulan").append(img);
            $(this).parent().remove();
        });
		var num=Math.floor(Math.random()*1000000+1);
		$("#text").val(num);
	});
</script>
</head>
<body style="font-size: 20px;">
	<div class="top" style="padding: 20px 30px 10px; font-size: 16px;">
		<a href="#">商品</a>/
		<a href="#">商品管理</a>/
		<span>商品列表</span>
	</div>
	<div class="bottom">
		<div class="span12" style="width: 96%;">
		<c:if test="${not empty goods}"><form action="goodslist?action=revise" method="post"></c:if>
		<c:if test="${empty goods}"><form action="goodslist?action=add" method="post"></c:if>
			<div class="box">
				<ul class="header">
					<li style="border-top: 2px blue solid;">商品信息</li>
					<li>描述</li>
				</ul>
			</div>
			<div class="box2">
				<ul>
					<li style="width: 100%;">
						<table class="table">
							<tr>
								<td style="text-align: right; width: 200px;">商品编号：</td>
								<td><input id="text" type="text" name="g_code" value="${goods.getG_code()}" style="width: 100%;" readonly="readonly"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">商品名称：</td>
								<td><input id="text" type="text" name="g_name" value="${goods.getG_name()}" style="width: 100%;"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">商品关键词：</td>
								<td><input id="text" type="text" name="g_keyword" value="${goods.getG_keyword()}" style="width: 100%;"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">所属分类：</td>
								<td>
									<select name="classify" style="width:100px;">
										<c:forEach items="${list}" var="u" varStatus="vs">
											<option value="${u.classify}">${u.classify}</option>
										</c:forEach>
									</select>
								</td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">是否上架：</td>
								<td>
									<input type="radio" name="g_state" value="是" ${goods.getG_state() eq 0? 'checked="checked"':''}>是
									<input type="radio" name="g_state" value="否" ${goods.getG_state() eq 1? 'checked="checked"':''}>否
									<input type="radio" name="g_state" value="待审" ${goods.getG_state() eq 2? 'checked="checked"':''}>待审
								</td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">是否免运费：</td>
								<td>
									<input type="radio" name="fare" value="是" ${goods.getFare() eq 0? 'checked="checked"':''}>是
									<input type="radio" name="fare" value="否" ${goods.getFare() > 0? 'checked="checked"':''}>否
									<input type="text" name="farenum" style="width:253px" value="${goods.getFare()}">
								</td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">排序：</td>
								<td><input id="text" type="text" name="sort" value="${goods.getSort()}" style="width: 100%;"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">商品单价：</td>
								<td><input id="text" type="text" name="g_price" value="${goods.getG_price()}" style="width: 100%;"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">库存：</td>
								<td><input id="text" type="text" name="g_stock" value="${goods.getG_stock()}" style="width: 100%;"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">规格名称：</td>
								<td><input id="text" type="text" name="f_name" value="无" style="width: 100%;"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">商品推荐：</td>
								<td>
									<input type="radio" name="g_groom" value="最新商品" ${goods.getG_groom() eq '最新商品'? 'checked="checked"':''}>最新商品
									<input type="radio" name="g_groom" value="特价商品" ${goods.getG_groom() eq '特价商品'? 'checked="checked"':''}>特价商品
									<input type="radio" name="g_groom" value="热卖商品" ${goods.getG_groom() eq '热卖商品'? 'checked="checked"':''}>热卖商品
									<input type="radio" name="g_groom" value="推荐商品" ${goods.getG_groom() eq '推荐商品'? 'checked="checked"':''}>推荐商品
								</td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">品牌名称：</td>
								<td>
								<input id="text" type="text" name="b_name" value="随便" style="width: 100%;"></td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;">产品相册：</td>
								<td>
									<input type="file" name="img" id="xdaTanFileImg" accept="image/*"/>
									<c:if test="${not empty goods}">
										<input type="hidden" name="p_newname" value="1">
										<input type="hidden" name="p_oldname" value="1">
										<input type="hidden" name="p_width" value="1">
										<input type="hidden" name="p_height" value="1">
										<input type="hidden" name="p_size" value="1">
									</c:if>
								</td>
							</tr>
							<tr>
								<td style="text-align: right; width: 200px;"></td>
								<td id="yulan">
									<c:if test="${not empty goods}">
										<input type="hidden" name="delete_code" value="1">
									</c:if>
									<c:if test="${not empty photos}">
										<c:forEach items="${photos}" var="u" varStatus="vs">
											<div style="float:left;">
												<img alt="" src="${u.getP_newname()}" style="cursor:pointer ;width:100px">
												<a href="javascript:;" class="closeimg" id="${u.getP_code()}"><i class="fa fa-close"></i></a>
											</div>
										</c:forEach>
									</c:if>
								</td>
							</tr>
						</table>
					</li>
					<li style="display: none;">
						<div>
							<script id="details" name="g_describe" type="text/plain">${goods.getG_describe()}</script>
						</div>
						<!-- 实例化编辑器 -->
	    				<script type="text/javascript">
	        				var ue = UE.getEditor('details');
	    				</script>
					</li>
				</ul>
			</div>
			<div class="span12" style="width: 96%;padding-left: 50%;"><input type="submit" value="发布商品"></div>
		</form>
		</div>
	</div>
</body>
</html>